package com.pj.project.sys_audio;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.pj.project4sp.SP;
import com.pj.utils.sg.AjaxJson;
import com.pj.utils.sg.SoMap;

import cn.dev33.satoken.stp.StpUtil;

/**
 * Controller: sys_audio -- 音频表
 * @author shengzhang 
 */
@RestController
@RequestMapping("/SysAudio/")
public class SysAudioController {

	/** 底层 Mapper 对象 */
	@Autowired
	SysAudioMapper sysAudioMapper;

	// 增  
	@RequestMapping("add")
	AjaxJson add(SysAudio s){
		StpUtil.checkPermission("sys-audio");	// 鉴权 
		int line = sysAudioMapper.add(s);
		return AjaxJson.getByLine(line);
	}

	// 删  
	@RequestMapping("delete")
	AjaxJson delete(long id){
		StpUtil.checkPermission("sys-audio");	// 鉴权 
		int line = sysAudioMapper.delete(id);
		return AjaxJson.getByLine(line);
	}
	
	/** 删 - 根据id列表 */  
	@RequestMapping("deleteByIds")
	AjaxJson deleteByIds(){
		StpUtil.checkPermission("sys-audio");	// 鉴权 
		List<Long> ids = SoMap.getRequestSoMap().getListByComma("ids", long.class); 
		int line = SP.publicMapper.deleteByIds("sys_audio", ids);
		return AjaxJson.getByLine(line);
	}

	// 改  
	@RequestMapping("update")
	AjaxJson update(SysAudio s){
		StpUtil.checkPermission("sys-audio");	// 鉴权 
		int line = sysAudioMapper.update(s);
		return AjaxJson.getByLine(line);
	}

	// 查  
	@RequestMapping("getById")
	AjaxJson getById(long id){
		// StpUtil.checkPermission("sys-audio");	// 鉴权 
		SysAudio s = sysAudioMapper.getById(id);
		return AjaxJson.getSuccessData(s);
	}

	// 查 - 集合（参数为null或0时默认忽略此条件）  
	@RequestMapping("getList")
	AjaxJson getList() { 
		// StpUtil.checkPermission("sys-audio");	// 鉴权 
		SoMap so = SoMap.getRequestSoMap();	// 获取本次请求参数 
		so.startPage();	// 开启分页
		List<SysAudio> list = sysAudioMapper.getList(so);	// 查询数据 
		return AjaxJson.getPageData(so.getDataCount(), list);
	}
	

}
